import java.util.Vector;

/**
 * 
 */

/**
 * Class that represents races
 * @author jmaria_iturbe
 *
 */
public class Race {
	
	private String name;
	private Circuit circuit;
	private Vector<Kart> participants;
	
	/**
	 * Default constructor with Vector
	 * @param name
	 * @param circuit
	 */
	public Race(String name, Circuit circuit) {
		this.name = name;
		this.circuit = circuit;
		participants = new Vector<Kart>();
		
	}
	
	/**
	 * Method to add vehicles to vector
	 * @param v
	 */
	public void addkart (Kart k) {
		participants.add(k);
	}
	
	/**
	 * Method to make the karts run (unfinished)
	 * @return
	 */
	public String run() {
		String winner = "";
		int won =0;
		int turn = 1;
		int pos = 0;
		int[] move=new int[participants.size()];
		do {
			move[pos]=move[pos] + participants.get(pos).move();
			pos++;
			for (int i = 0; i < move.length-1; i++) {
				int pole = 0;
				if (move[i] > pole || move[i] > move[i-1]) {
					pole = move [i];
					if (pole >=circuit.getKm()){
						participants.elementAt(move[i]);
					}
				}
			}
			turn= turn*2;
					
		} while (turn < move[pos]);
				
			
		return winner;
	}

}
